package com.jasonchoi.eurekaconsumer.controller;

import com.jasonchoi.eurekaconsumer.consume.HelloFeignConsumer;
import com.jasonchoi.eurekaconsumer.consume.HelloRibbonConsumer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Spring cloud 远程调用
 * 2 * @Author: JasonChoi
 * 3 * @Date: 2019/12/11 17:16
 * 4
 */
@RestController
public class HelloConsumeController {
    @Autowired
    HelloFeignConsumer helloFeignConsumer;
    @Autowired
    HelloRibbonConsumer helloRibbonConsumer;


    /**
     * 方式1 feign
     * @param name
     * @return
     */
    @RequestMapping("/hello/{name}")
    public String index(@PathVariable("name") String name) {
        return helloFeignConsumer.hello(name);
    }

    /**
     * 方式2 ribbon + restTemplate
     * @param name
     * @return
     */
    @RequestMapping("/ribbon/hello/{name}")
    public String index4Ribbon(@PathVariable("name") String name) {
        return helloRibbonConsumer.hello(name);
    }
}
